package com.no1.musicmgr.service;

import com.no1.musicmgr.entity.Comments;
import com.no1.musicmgr.mapper.CommentsMapper;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
@Service
public class CommentsService {
    @Autowired
    private CommentsMapper commentsMapper;
    @Schema(description = "新增评论")
    public boolean addComments(Comments comments) {
        return commentsMapper.addComments(comments);
    }
    @Schema(description = "删除评论")
    public boolean deleteComments(Integer commentsId) {
        return commentsMapper.deleteComments(commentsId);
    }
    @Schema(description = "改写评论")
    public boolean updateComments(Comments comments) {
        return commentsMapper.updateComment(comments);
    }
    @Schema(description = "查询评论(单)")
    public Comments selectComments(Comments comments) {
        try {
            return commentsMapper.selectComments(comments);
        }catch (Exception e) {
            return new Comments();
        }
    }
    @Schema(description = "查询评论(多查)")
    public ArrayList<Comments> listComments(Comments comments) {
        try {
            return commentsMapper.listComments(comments);
        }catch (Exception e) {
            return new ArrayList<>();
        }
    }

    public Comments selectById(Integer commentsId) {
        return commentsMapper.selectById(commentsId);
    }


}
